﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Misc.Common.OneInstance;
using Misc.Common.Exceptions;
using ComponentFactory.Krypton.Toolkit;
using System.Reflection.Emit;
using BLToolkit.TypeBuilder;
using LED_Editor.Config;
using System.Reflection;
using LED_Editor.ControllerProgramming;

namespace LED_Editor {
	static class Program {
		static bool IsTestMode = false;
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(params string[] array) {
			if (CheckOneInstance.IsInstanceExist(true))
				return;

			LedEditorConfig.LocalConfigName = "LED.config";
			ExceptionReporter.EnableEMailSending = true;
			UnhandledExceptionsReporter.ExceptionHandlersRegistred = true;
			FramesConverter.AddEmptyFrameAtEnd = false;
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);

			if (IsTestMode) {
				Application.Run(new TestControllerProgramming());
				return;
			}
			MainLedXForm main = new MainLedXForm();
			if (main is KryptonForm)
				((KryptonForm)main).PaletteMode = PaletteMode.Office2007Black;
			if (array != null && array.Length > 0)
				main.OpenFile(array[0]);
			Application.Run(main);
			//TypeFactory.SaveTypes = true;
			//TypeFactory.SetGlobalAssembly(Application.StartupPath + "\\BLToolkitGenerated.dll");
			//Application.ApplicationExit += delegate { TypeFactory.SaveGlobalAssembly(); };

			//Application.Run(new Form1());

			//Application.Run(new TestControllerProgramming ());
		}
	}
}

